package org.alvin.i18n.newui;

import com.alibaba.fastjson.JSONObject;

public class I18nV3ServiceV2 extends I18nV2ServiceV2 {


    public String doTransferScript(String scriptContent, JSONObject res, String fileName, String callStr) {
        String content = super.doTransferScript(scriptContent, res, fileName, "t");
        if (content.contains("useI18n")) {
            return content;
        }
        int pos = content.indexOf("const ");
        if (pos == -1) {
            System.out.println("没有插入国际化：" + fileName);
            return content;
        }
        StringBuilder sb = new StringBuilder(content);
        sb.insert(pos, "\r\n\timport { useI18n } from 'vue-i18n';\r\n\tconst { t } = useI18n();\r\n\t");
        return sb.toString();
    }


    public String transferScriptByText(String scriptContent, JSONObject res, String fileName, String callStr) {
        return super.transferScriptByText(scriptContent, res, fileName, "t");
    }
}
